/*
 * @Author: ischen.x ischen.x@foxmail.com
 * @Date: 2024-07-11 13:31:52
 * @LastEditors: ischen.x ischen.x@foxmail.com
 * @LastEditTime: 2024-07-19 16:17:23
 * 
 * Copyright (c) 2024 by ischen.x, All Rights Reserved. 
 */

#ifndef __DS1339_H
#define __DS1339_H

#include <stdint.h>
#include <time.h>

#define DS1339_IIC_ADDR	0xD0

typedef struct ds1339 {
	uint8_t Seconds;
	uint8_t Minutes;
	uint8_t Hours;
	uint8_t Day;
	uint8_t Date;
	uint8_t Mounth_Century;
	uint8_t year;
    uint8_t Alarm_1_Seconds;
    uint8_t Alarm_1_Minutes;
    uint8_t Alarm_1_Hours;
    uint8_t Alarm_1_Day_Date;
    uint8_t Alarm_2_Minutes;
    uint8_t Alarm_2_Hours;
    uint8_t Alarm_2_Day_Date;
    uint8_t Control;
    uint8_t Status;
    uint8_t Trickle_Charger;
}ds1339_reg_type;

int ds1339_get_time(struct tm *time_struct);
int ds1339_set_time(struct tm *time_struct);
int ds1339_set_read_write_function(int(*read)(uint8_t, uint8_t *, uint8_t), int(*write)(uint8_t, uint8_t *, uint8_t));

#endif /* __DS1339_H */

